﻿<phone:PhoneApplicationPage
    x:Class="BindableApplicationBar.TestApp.Views.PropertyBindingTestPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:bar="clr-namespace:BindableApplicationBar;assembly=BindableApplicationBar"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"
    Orientation="Portrait"
    mc:Ignorable="d"
    d:DesignHeight="696"
    d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding PropertyBindingTest, Source={StaticResource ViewModelLocator}}"
    x:Name="page">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid
        x:Name="LayoutRoot"
        Background="Transparent">
        <!--ContentPanel - place additional content here-->
        <Grid
            x:Name="ContentPanel"
            Grid.Row="1"
            Margin="12,0,12,0">
            <ScrollViewer
                ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <StackPanel>
                    <TextBlock
                        Text="BindableApplicationBar tests"
                        Foreground="Red" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <TextBlock
                        Text="Opacity" />
                    <Border
                        BorderBrush="#40808080"
                        BorderThickness="1">
                        <Slider
                            Minimum="0"
                            Maximum="1.0"
                            SmallChange="0.001"
                            Value="{Binding Opacity, Mode=TwoWay}" />
                    </Border>

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="ForegroundColor" />
                        <TextBlock
                            Text="{Binding ForegroundColor, Converter={StaticResource DoubleToColorConverter}, ConverterParameter=name}"
                            Margin="15,0,0,0" />
                    </StackPanel>
                    <Border
                        BorderBrush="#40808080"
                        BorderThickness="1">
                        <Slider
                            Minimum="0"
                            Maximum="0.999"
                            SmallChange="0.001"
                            Height="90"
                            Value="{Binding ForegroundColor, Mode=TwoWay}"
                            Background="#40FFFFFF" />
                    </Border>

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="BackgroundColor:" />
                        <TextBlock
                            Text="{Binding BackgroundColor, Converter={StaticResource DoubleToColorConverter}, ConverterParameter=name}"
                            Margin="15,0,0,0" />
                    </StackPanel>
                    <Border
                        BorderBrush="#40808080"
                        BorderThickness="1">
                        <Slider
                            Minimum="0"
                            Maximum="0.999"
                            SmallChange="0.001"
                            Height="90"
                            Value="{Binding BackgroundColor, Mode=TwoWay}"
                            Background="#40FFFFFF" />
                    </Border>

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding BarIsVisible, Mode=TwoWay}"
                        Content="IsVisible" />
                    <CheckBox
                        IsChecked="{Binding ModeBool, Mode=TwoWay}">
                        <StackPanel
                            Orientation="Horizontal">
                            <TextBlock
                                Text="Mode:" />
                            <TextBlock
                                Text="{Binding ModeString}"
                                Margin="15,0,0,0" />
                        </StackPanel>
                    </CheckBox>

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding IsMenuEnabled, Mode=TwoWay}"
                        Content="IsMenuEnabled" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding IsMenuVisible}"
                        IsEnabled="False"
                        Content="IsMenuVisible (with IsMenuEnabled)" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <Line
                        StrokeThickness="2"
                        Stroke="#80808080"
                        X1="0"
                        X2="480" />
                    <!-- spacing -->
                    <Grid
                        Height="12" />

                    <TextBlock
                        Text="Button tests"
                        Foreground="Red" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <TextBlock
                        Text="Button 1 - IconUri" />
                    <StackPanel
                        Orientation="Horizontal">
                        <RadioButton
                            GroupName="IconChoice"
                            IsChecked="{Binding FirstIconChoice, Mode=TwoWay}">
                            <Image
                                Source="/Icons/Dark/appbar.add.rest.png"
                                Stretch="None" />
                        </RadioButton>
                        <RadioButton
                            GroupName="IconChoice"
                            IsChecked="{Binding SecondIconChoice, Mode=TwoWay}">
                            <Image
                                Source="/Icons/Dark/appbar.minus.rest.png"
                                Stretch="None" />
                        </RadioButton>
                    </StackPanel>

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <TextBlock
                        Text="Button 1 - Text" />
                    <TextBox
                        Text="{Binding IconButtonText, Mode=TwoWay}" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding ButtonIsEnabled, Mode=TwoWay}"
                        Content="Button 1 - IsEnabled" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding TestCommandParameter, Mode=TwoWay}"
                        Content="Button 2 - CommandParameter" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <Button
                        Content="Remove non-bindable button"
                        Command="{Binding RemoveNonBindableButtonCommand}"
                        CommandParameter="{Binding ElementName=page}" />
                    <Button
                        Content="Add non-bindable button"
                        Command="{Binding AddNonBindableButtonCommand}"
                        CommandParameter="{Binding ElementName=page}" />
                    <Button
                        Content="Remove data-bound button"
                        Command="{Binding RemoveButtonCommand}" />
                    <Button
                        Content="Add data-bound button"
                        Command="{Binding AddButtonCommand}" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <Line
                        StrokeThickness="2"
                        Stroke="#80808080"
                        X1="0"
                        X2="480" />
                    <!-- spacing -->
                    <Grid
                        Height="12" />

                    <TextBlock
                        Text="Menu item tests"
                        Foreground="Red" />

                    <!-- spacing -->
                    <Grid
                        Height="24" />
                    <TextBlock
                        Text="Menu Item 1 - Text" />
                    <TextBox
                        Text="{Binding MenuItemText, Mode=TwoWay}" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding MenuItemIsEnabled, Mode=TwoWay}"
                        Content="Menu Item 1 - IsEnabled" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <CheckBox
                        IsChecked="{Binding TestCommand2Parameter, Mode=TwoWay}"
                        Content="Menu Item 2 - CommandParameter" />

                    <!-- spacing -->
                    <Grid
                        Height="12" />
                    <Button
                        Content="Remove non-bindable menu item"
                        Command="{Binding RemoveNonBindableMenuItemCommand}"
                        CommandParameter="{Binding ElementName=page}" />
                    <Button
                        Content="Add non-bindable menu item"
                        Command="{Binding AddNonBindableMenuItemCommand}"
                        CommandParameter="{Binding ElementName=page}" />
                    <Button
                        Content="Remove data-bound menu item"
                        Command="{Binding RemoveMenuItemCommand}" />
                    <Button
                        Content="Add data-bound menu item"
                        Command="{Binding AddMenuItemCommand}" />

                    <!-- padding -->
                    <Grid
                        Height="72" />
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </Grid>

    <bar:Bindable.ApplicationBar>
        <bar:BindableApplicationBar
            IsVisible="{Binding BarIsVisible}"
            IsMenuVisible="{Binding IsMenuVisible, Mode=TwoWay}"
            IsMenuEnabled="{Binding IsMenuEnabled}"
            ForegroundColor="{Binding ForegroundColor, Converter={StaticResource DoubleToColorConverter}}"
            BackgroundColor="{Binding BackgroundColor, Converter={StaticResource DoubleToColorConverter}}"
            BindableOpacity="{Binding Opacity}"
            Mode="{Binding Mode}"
            MenuItemsSource="{Binding MenuItems}"
            ButtonsSource="{Binding Buttons}">
            <!--<bar:BindableApplicationBar.MenuItemTemplate>
                <DataTemplate>
                    <bar:BindableApplicationBarMenuItem
                        Text="{Binding Text}"
                        Command="{Binding Command}"
                        CommandParameter="{Binding CommandParameter}"/>
                </DataTemplate>
            </bar:BindableApplicationBar.MenuItemTemplate>-->
            <bar:BindableApplicationBarButton
                Text="{Binding IconButtonText}"
                IconUri="{Binding IconUri, FallbackValue=/Icons/Dark/appbar.add.rest.png}"
                IsEnabled="{Binding ButtonIsEnabled}" />
            <bar:BindableApplicationBarButton
                Text="XAML Btn 2"
                IconUri="/Icons/Dark/appbar.next.rest.png"
                Command="{Binding TestCommand}"
                CommandParameter="{Binding TestCommandParameter}" />
            <bar:BindableApplicationBar.MenuItems>
                <bar:BindableApplicationBarMenuItem
                    Text="{Binding MenuItemText}"
                    IsEnabled="{Binding MenuItemIsEnabled}" />
                <bar:BindableApplicationBarMenuItem
                    Text="XAML MnuIt 2"
                    Command="{Binding TestCommand2}"
                    CommandParameter="{Binding TestCommand2Parameter}" />
            </bar:BindableApplicationBar.MenuItems>
        </bar:BindableApplicationBar>
    </bar:Bindable.ApplicationBar>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar
            IsVisible="True"
            IsMenuEnabled="True">
            <shell:ApplicationBarIconButton
                IconUri="/Images/appbarthis.button1.png"
                Text="Button 1" />
            <shell:ApplicationBarIconButton
                IconUri="/Images/appbarthis.button2.png"
                Text="Button 2" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem
                    Text="MenuItem 1" />
                <shell:ApplicationBarMenuItem
                    Text="MenuItem 2" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
